package com.mc.designpattern.factory.factory1;

import com.mc.designpattern.factory.factory2.Api;
import com.mc.designpattern.factory.factory2.Factory;
import com.mc.designpattern.strategy.service.IOrderChannelService;
import com.mc.result.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.ResponseBody;

@Controller
public class FactoryController {
    @Autowired
    IOrderChannelService channelService;

    @Autowired
    ExportFileApi exportTxtFile;

    @Autowired
    ExportFileApi exportDB;

    @PostMapping("/factory/f1")
    @ResponseBody
    public Result handleOrder(Integer type) {

        ExportOperate exportOperate = new ExportOperate(exportTxtFile, exportDB);
        exportOperate.export(type, "234");

        return Result.success(null);
    }


    @PostMapping("/factory/f2")
    @ResponseBody
    public Result handleOrder2(Integer type) {

        Api api = Factory.createApi();
        api.doAction(type+"");

        return Result.success(null);
    }

}
